﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Sauces.Bussinees.Entities.Caja;
using Sauces.Bussinees.Entities.Almacen;
using Sauces.Bussinees.Logic.Service;
using Sauces.Bussinees.Logic.Caja.Service;
using Microsoft.Practices.Unity;
using System.Web.ModelBinding;

namespace Sauces.Web.Caja
{
    public partial class FrmListaFatura : System.Web.UI.Page
    {
        [Dependency]
        public IFacturaService facturaService { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            var opc = Request.QueryString["opc"];
            var IdFactura = Request.QueryString["id"];
            
            if (opc != null && opc == "delete" && IdFactura != null)
            {
                var id = Int32.Parse(IdFactura.ToString());
                facturaService.removeFactura(id);                
            }
            
        }

        public IEnumerable<Factura> GetFactura([Control("txtCriterio")] string criterio,
                                      [Control("txtFechaInicio")] DateTime? fechaIni,
                                      [Control("txtFechaFin")]DateTime? fechaFin)
        {
            return facturaService.getAllBoletaByNombreAndFechas(criterio, fechaIni, fechaFin);
        }

        
    }
}